<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
    .box {
        width: 400px;
        height: 400px;
        background-color: yellowgreen;
    }

    .box1 {
        width: 400px;
        height: 400px;
        background-color: orangered;
    }
</style>

<body>
    <div id="app">
        <div :class="flag?'box':'box1'"></div>
        <button @click='chang'>改变</button>
    </div>
</body>

<script>
    const vm = new Vue({
        el: '#app',
        data: {
            boxClass: 'box',
            flag: false
        },
        methods: {
            chang() {
                console.log('点击改变颜色');
                this.flag = !this.flag
            }
        }
    })
</script>

</html>